from fct_rest_platform import settings
from fct_rest_platform.settings import cate_teacher, cate_student, area, roll, kid
from fct_rest_platform.utils.debugtalk import get_hold_time


# 获取环境
def get_environment(request):
    envi = request.get('environment')
    uri = settings.config
    url = uri.get(envi)
    return url


# 构造教师学生登录入参
def construct_parameter(request, cate):
    param = dict()
    if cate == 2:
        param['phone'] = request.get('phone_teacher')
        param['pw'] = request.get('pw_teacher')
        param['area'] = area
        param['cate'] = cate_teacher
    elif cate == 1:
        param['phone'] = request.get('phone_student')
        param['pw'] = request.get('pw_student')
        param['area'] = area
        param['cate'] = cate_student
    else:
        param = {}
    return param


# 构造打开授课接口入参
def construct_parameter_open(token, mid):
    param = dict()
    param['onlyofficial'] = True
    param['cate'] = cate_teacher
    param['h_m'] = mid
    param['token'] = token
    param['roll'] = roll
    param['stamp'] = get_hold_time(7)
    return param


# 构造学生预约课程接口入参
def construct_parameter_holdtime(mid, uid, token):
    param = dict()
    param['cate'] = cate_student
    param['teaid'] = mid
    param['h_m'] = uid
    param['token'] = token
    param['kid'] = kid
    param['stamp'] = get_hold_time(7)
    return param
